package com.sobot.h5.demo;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

import com.sobot.utils.SobotStringUtils;
import com.sobot.widget.SobotWidgetApi;
import com.sobot.widget.ui.SobotMarkConfig;
import com.sobot.widget.ui.toast.SobotToastUtil;
import com.sobot.widget.ui.webview.SobotWebViewActivity;


public class MainActivity extends Activity {

    private static final String TAG = "MainActivity";

    private Context context;
    private EditText address, address2, address3, address4;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        address = (EditText) findViewById(R.id.address);
        address2 = (EditText) findViewById(R.id.address2);
        address3 = (EditText) findViewById(R.id.address3);
        address4 = (EditText) findViewById(R.id.address4);
        address.setText("https://ccc.sobot.com/chat/h5/v2/index.html?sysnum=75574e5fa29a48458d1f57ab5489a4c5");
//        address2.setText("https://ccc.sobot.com/chat/h5/v2/index.html?sysnum=75574e5fa29a48458d1f57ab5489a4c5&source=2");
//        address3.setText("https://www.sobot.com/ticketclient/index.html?sysNum=75574e5fa29a48458d1f57ab5489a4c5&deployId=d141e7a9c6d74d7b9285f694188bd66a");

        findViewById(R.id.sobot_btn).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startSobotMainActivity(address.getText().toString());
            }
        });

        findViewById(R.id.sobot_btn2).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startSobotMainActivity(address2.getText().toString());
            }
        });

        findViewById(R.id.sobot_btn3).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startSobotMainActivity(address3.getText().toString());
            }
        });

        findViewById(R.id.sobot_btn4).setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                startSobotMainActivity(address4.getText().toString());
            }
        });
    }

    public void startSobotMainActivity(String url) {
        //横竖屏设置 默认false 竖屏， true 横屏
        //SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.LANDSCAPE_SCREEN, false);
        //水滴屏适配开关，只有横屏才生效 默认false 关闭， true 开启
        //SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.DISPLAY_INNOTCH, false);
        //是否弹出权限用途提示框，建议开启，如果不开启有可能导致应用市场发布发布时审核不通过
        SobotWidgetApi.setSwitchMarkStatus(SobotMarkConfig.SHOW_PERMISSION_TIPS_POP, true);

        if (SobotStringUtils.isEmpty(url)) {
            SobotToastUtil.showCustomToast(MainActivity.this, "跳转链接不能为空");
            return;
        }
        Intent intent = new Intent(MainActivity.this, SobotWebViewActivity.class);
        intent.putExtra("url", url);
        //是否隐藏头部导航栏 默认false显示， true 隐藏
        //intent.putExtra("isHideTitleBar", true);
        //是否隐藏底部工具栏 默认false显示， true 隐藏
        //intent.putExtra("isHideToolBar", true);
        startActivity(intent);
    }
}